<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div id='app'>
        <button v-text='msg' @click='time' :disabled='fiag'></button>
    </div>
    <script>
    const vm = new Vue({
        el: '#app',
        data: {
            flag:false,
            msg:'获取验证码',
            sec:60
        },
        methods:{
            time(){
                this.flag=true
                let timer=setInterval(()=>{
                    this.sec--,
                    this.msg=this.sec+'s后重新发送'
                    if(!this.sec){
                        clearInterval(timer)
                        this.flag=false
                        this.sec=60
                        this.msg='获取验证码'

                    }
                },1000)
            }
        }
    })
    </script>
</body>
</html>